def outer(func):
    def inner():
        print('开始延迟')
        func()
        print('延迟结束') 
    return inner
def yanchi():
    import random
    import time
    seconds = random.randint(1,5)
    print(f"延迟{seconds}秒")
    time.sleep(seconds)
'''
fn = outer(yanchi)
fn()
'''
# 糖写法
@outer  # 定义在目标函数之上，和第14行功能一致
def yanchi_2():
    import random
    import time
    seconds = random.randint(1,5)
    print(f"延迟{seconds}秒")
    time.sleep(seconds)
yanchi_2()